/* eslint valid-jsdoc: "off" */
'use strict'

module.exports = (appInfo) => {
  const config = (exports = {})

  config.keys = appInfo.name + '_1634890332352_257'

  config.middleware = ['errorHandler']

  // swagger接口文档描述信息
  config.swaggerdoc = {
    dirScanner: './app/controller',
    apiInfo: {
      title: '开课吧接⼝',
      description: '开课吧接⼝ swagger-ui for egg',
      version: '1.0.0',
    },
    schemes: ['http', 'https'],
    consumes: ['application/json'],
    produces: ['application/json'],
    enableSecurity: false,
    routerMap: true,
    enable: true,
  }

  // mongoose配置
  config.mongoose = {
    // egg_test是数据库名称
    url: 'mongodb://127.0.0.1:27017/egg_test',
    options: {
      autoReconnect: true,
      reconnectTries: Number.MAX_VALUE,
      bufferMaxEntries: 0,
    },
  }

  // 鉴权配置
  config.jwt = {
    secret: 'Great4-M',
    enable: true, // default is false
    match: /^\/api/, // optional
  }

  const userConfig = {}

  return {
    ...config,
    ...userConfig,
  }
}
